/**
 * Project Name:sc-parent-service
 * File Name:CustomerServiceImpl.java
 * Package Name:com.sc.service.impl
 * Date:2018年6月28日下午2:48:53
 * Copyright (c) 2018, bluemobi All Rights Reserved.
 */

package com.sc.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.sc.mapper.mapperauto.CustomerMapper;
import com.sc.mapper.mapperhand.HandcustomerMapper;
import com.sc.pojo.Customer;
import com.sc.probabilitycount.ProbabilityCount;
import com.sc.service.CustomerService;

/**
 * Description: <br/>
 * Date: 2018年6月28日 下午2:48:53 <br/>
 * 
 * @author tianyongxu
 * @version
 * @see
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    // 将mapper注入给service

    @Autowired
    private HandcustomerMapper customerMapper;

    @Autowired
    private CustomerMapper cm;
    
    @Override
    @Cacheable(cacheNames={"customer"})
    public List<Customer> selectCustomers() {
        System.out.println("在数据库查-----》");
        return customerMapper.selectCustomers();
    }

    @Override
    public List<Customer> selectCustomersByEmpId(Integer eid) {

        return customerMapper.selectCustomersByEmpId(eid);
    }

    @Override
    public List<Customer> selectbyPhone(String cphone) {

        // Auto-generated method stub
        return customerMapper.selectbyPhone(cphone);
    }

    /**
     * 计算单个对象概率值的方法
     */
    @Override
    public float selectBuyHouseProbability(Customer customer) {

        // return ProbabilityCalculator.calculate(customer); 这个方法有问题，一个线程跑不下来
        return ProbabilityCount.countProbability(customer);// 调用计算机的方法
    }

    /**
     * 通过id删除员工的信息
     */
    @Override
    public int deleteByPrimaryKey(Integer cid) {

        return customerMapper.deleteByPrimaryKey(cid);
    }

    /**
     * 修改客户信息
     */
    @Override
    public int updateByPrimaryKeySelective(Customer record) {

        // Auto-generated method stub
        return customerMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 按照客户等级排名查询
     */
    @Override
    public List<Customer> selectCustomersByGrand() {

        // Auto-generated method stub
        return customerMapper.selectCustomersByGrand();
    }
    /**
     * 查询某个客户信息通过id
     * */
    @Override
    public Customer selectCustomersByCid(Integer cid) {

        // Auto-generated method stub
        return customerMapper.selectCustomersByCid(cid);
    }
    /**
     * 模糊查询信息
     * */

    @Override
    public List<Customer> selectDynamicByInfo(Map<String, Object> map) {

        // Auto-generated method stub
        return customerMapper.selectDynamicByInfo(map);
    }

    @Override
    public List<Customer> selectByEmIdCuInfo(Integer eid) {

        // Auto-generated method stub
        return customerMapper.selectByEmIdCuInfo(eid);
    }


    @Override
    public int insert(Customer record) {


        // Auto-generated method stub
        return customerMapper.insert(record);
    }

    @Override
    public int insertReport(Map<String, Object> paramMap) {

        // Auto-gene.rated method stub
        return customerMapper.insertReport(paramMap);
    }

    @Override
    public List<Customer> selectCustomerOrderByEid(Integer eid) {
        
        //  Auto-generated method stub
        return customerMapper.selectCustomerOrderByEid(eid);
    }

    @Override
    public int updateByIdApp(Map<String, Object> paramMap) {
        
        //  Auto-generated method stub
        return customerMapper.updateByIdApp(paramMap);
    }

    @Override
    public List<Customer> selectCustomersLike(String cname) {
        
        //  Auto-generated method stub
        return customerMapper.selectCustomersLike(cname);
    }

    @Override
    public List<Customer> selectCustomerByHouseType(Integer eid) {
        
        //  Auto-generated method stub
        return customerMapper.selectCustomerByHouseType(eid);
    }

    @Override
    public String selectImageByCid(Integer cid) {
        
        //  Auto-generated method stub
        return customerMapper.selectImageByCid(cid);
    }

    @Override
    public Customer selectByCid(Integer cid) {
        
        //  Auto-generated method stub
        return customerMapper.selectByCid(cid);
    }

    @Override
    public int updateByCustomer(Customer customer) {
        
        //  Auto-generated method stub
        return cm.updateByCustomer(customer);
    }

    @Override
    public Map<String, Object> selectCuEachrtsBycid(Integer cid) {
        
        //  Auto-generated method stub
        return customerMapper.selectCuEachrtsBycid(cid);
    }

   

}
